package com.shopping.mall.core.module.type.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
import java.util.List;

/**
 * Type实体类
 *
 * @author zzy
 * @date 2021-08-11
 */
@Data
@TableName("type")
public class Type {

    public interface insert {
    }

    public interface update {
    }

    @ApiModelProperty(value = "主键")
    @TableId(type = IdType.UUID)
    private String id;

    @ApiModelProperty(value = "类型")
    private String type;

    @ApiModelProperty(value = "父节点ID,0为根节点")
    private String parentId;

    @ApiModelProperty(value = "级别（最高三级）")
    private Integer level;

    @ApiModelProperty(value = "描述信息")
    private String description;

    @ApiModelProperty(value = "图片")
    private String photo;

    @ApiModelProperty(value = "排序号")
    private Integer orderNum;

    @TableField(exist = false)
    @ApiModelProperty(value = "语言ID")
    private String languageId;

    @TableField(exist = false)
    @ApiModelProperty(value = "子节点")
    private List<Type> children;


    public Type() {
    }

    public Type(String id) {
        this.id = id;
    }

    public Type(String id, Integer orderNum) {
        this.id = id;
        this.orderNum = orderNum;
    }

    public Type(String id, String type, String parentId, Integer level, String description, String languageId) {
        this.id = id;
        this.type = type;
        this.parentId = parentId;
        this.level = level;
        this.description = description;
        this.languageId = languageId;
    }

    @JsonIgnore
    public TypeLan getTypeLan() {
        return new TypeLan(id, type, parentId, level, description, languageId);
    }
}
